<?php
// ====================================================
// filename:wl004_change_pw.php
// summary: 修改密码画面_提交
// ====================================================
require_once ("../init.php");
php_handle();

// 详细业务处理
function php_handle()
{
    // ======参数验证======
    $oldpw = md5($_POST["oldpw"]);
    $newpw = md5($_POST["newpw"]);
    $uid = $_SESSION['wl_uid'];
    
    // ======业务处理======
    $wlu02 = new wlu02tbx();
    $u02res = $wlu02->sel_wlu02tbx_check_pw($uid, $oldpw);
    if (count($u02res) == 0) {
        echo json_encode(array(
            'success' => false,
            'msg' => "输入的旧密码有误!"
        ));
        return;
    }
    
    $u02upd = array();
    $u02upd["user_id"] = $uid;
    $u02upd["user_pw"] = $newpw;
    
    $u02rec = $wlu02->update($uid, $u02upd);
    if ($u02rec == 0) {
        echo json_encode(array(
            'success' => false,
            'msg' => "密码更新失败!"
        ));
        return;
    }
    
    // ======结果返回======
    echo json_encode(array(
        'success' => true
    ));
    return;
}

?>